perm filename LSPLOT.S78[206,LSP]1 blob
sn#351110 filedate 1978-04-21 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00012 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 .if FALSE then begin "outline"
C00004 00003 .if FALSE then begin "improvements"
C00005 00004 .require "bkmac.pub[lsp,clt]" source_file
C00006 00005 .if TRUE then BEGIN "Title"
C00007 00006 .INSERT CONTENTS
C00008 00007 .s(PREFACE,Preface)
C00011 00008 .SET SECTIONPARS(I,1,Section,1)
C00012 00009 .s(LOTS,USING MACLISP AT LOTS)
C00016 00010 .ss Example of Interactive Session
C00020 00011 .ss Suggestions for Homework Preparation.
C00024 00012 .GET MICRO.S78[206,LSP]
C00026 ENDMK
C⊗;
.if FALSE then begin "outline"
LISP at LOTS handout
Intro--what to get out of this handout
Sample session
Invoking LISP
Interacting with the Interpreter
Defining functions
Grindeffing them
Editing them
Saving results in file
Inteacting with the world
reading files
writing files
appending to files
crunit
What to do when it says FASLOAD FILE not found
Reading files on CS206 area
Organization of homework
create a file with function definitions
read them into LISP and debugg
(possibly editing and saving the corrections)
prepare final defn file
photo session showing sample runs
appendices
micromanual
editor
oldio
.end "outline"
.if FALSE then begin "improvements"
add a list of functions available and brief description
(just include those most useful for course)
fix editor section
.end "improvements"
.require "bkmac.pub[lsp,clt]" source_file
.odd heading(, {sname}, {page}) ;
.even heading({page}, {sname}, ) ;
.MACRO GET(FILE) ⊂ BEGIN "FILE" REQUIRE "FILE" SOURCE_FILE
.END "FILE" ⊃
.if TRUE then BEGIN "Title"
.<<Title page for MACLISP at LOTS manual>>
.PORTION TITLEPAGE
.TURNON "{}"
.sname ← SSNAME ← NULL
.skip 20
.FONT A "SGN114"
.FONT B "SIGN57"
.center
.select A
MACLISP
.select B
.SKIP 1
AT
.SKIP 2
.select A
LOTS
.select 1
.skip 6
Compiled for CS206
.skip 2
by Carolyn Talcott
.SKIP 2
Stanford University
.skip 2
This version printed at {time} on {date}.
.TURN OFF
.END "Title"
.INSERT CONTENTS
.COUNT PAGE FROM 1 TO 999
.COUNT SECTION FROM 1 TO 999
.COUNT SUBSECTION IN SECTION FROM 1 TO 999
.sname ← SSNAME ← NULL
.turnon "{}"
.PORTION MAINPORTION
.SET SECTIONPARS(,,Preface,i)
.s(PREFACE,Preface)
This note is intended as an introduction to the use of the
student version of MACLISP currently available at the Stanford LOTS
Computing Center. It is particularly aimed at students in CS206.
In the first section we give a brief discussion of how to use MACLISP.
There is a "photo" of a sample session with the LISP interpreter
using the basic features that the student will need.
Some suggestions on the mechanics of writing, debugging, and preparing
results to turn in as homework are also given.
The second section is the MICRO MANUAL for LISP written by
John McCarthy. It contains a description of the primitives of LISP
their semantics and some useful abbreviations for pratical use.
As this contains discussion of only the very basic notions of LISP
it is essentially implementation independent and any reasonable LISP
should behave in this way (some abbreviations may have different
names).
The third section describes Input/Output in the Stanford
Version of MACLISP and includes a few examples of the use of
the I/O operations. The fourth section describes the MACLISP editor.
.SET SECTIONPARS(I,1,Section,1)
.itemmac
.s(LOTS,USING MACLISP AT LOTS)
.ss Introduction
The following is a brief introduction to the use of the student
version of MACLISP at LOTS.
This version can be run at LOTS by typing "LISP" to the LOTS monitor.
Allocation, initialization
of the Editor and other useful things are done automatically.
As with other LISP interpreters, the top level is a
read-eval-print loop. Type in an S-expression and LISP returns the value.
To exit LISP type <control>C.
This version of MACLISP has the I/O functions $DSKIN and $DSKOUT
which are similar to the functions of the same name in LISP1.6.
To input a file named FOO.BAR on your directory say $$(DSKIN_FOO_BAR)$.
If the file resides on one of the additional directories known to LISP
then $$(DSKIN_FOO_BAR_<name>)$ will read <name>FOO.BAR. One such directory
is CS206.
If the file resides on a directory unknown to LISP then the form of
the instruction is $$(DSKIN_FOO_BAR_DSK_(m_n))$ where $(m_n) is the system
account information for the directory concerned.
The Editor functions $SAVE and $REFILE can be used to save or update
function definitions.
The function $DSKOUT can be used to write on a file.
For example if $FF is a function taking one argument then
$$(DKSOUT_(PRINC_(FF_(QUOTE (A.B))))_FOO_BAR)$ creates a file FOO.BAR on
your directory and $$PRINC$'s the result of evaluating $$(FF (QUOTE (A.B)))$
on that file. More general I/O operations can be done using the
MACLISP I/O functions
$UREAD/UWRITE together with the appropriate control switches. These
are described in the I/O section.
Sometimes you will make error and a "breakpoint" will occur.
The system will type a message preceded by a ";" and perhaps
give you the option of correcting the error on the fly.
Usually the information that is typed will alert you to the
cause of the error; if not, you should read about errors and debugging
aids in a MACLISP manual. In any case, to get back to
the toplevel of MACLISP you type: $<control>G or $$(IOC_G)$.
(If the system replys with an error message and does not ask you
for a correction it is a good idea to do a <control>G just to
make sure you have returned the appropriate level.)
.ss Example of Interactive Session
The following is the log of a session with LISP at LOTS. Things
in lower case are typed by the user and those in UPPER case are generated
by LISP. A single semicolon ";" flags a comment made by LISP. A triple
semicolon ";;;" flags a comment made by the user.
.begin "session"
.select 6
.verbatim
@lisp
Student MacLisp Interpreter
RIGHT!
;;;ask LISP the value of some simple S-expressions
nil
NIL
t
T
(cons 'a 'b) ;;; 'a is an abbreviation for (quote a)
(A . B)
(car (cons 'a 'b))
A
(eq 'a (car (cons 'a 'b)))
T
;;;define a function called double
(defun double (x) (cons x x))
DOUBLE
;;;try it out
(double nil)
(NIL)
(double 1)
(1 . 1)
(double (double 1))
((1 . 1) 1 . 1)
;;;read in a file
(dskin gg lsp)
GG
DONE
;;;this file contained the definition of the function gg
;;;pretty print the definition of gg
(grindef gg)
(DEFUN GG (X) (COND ((ATOM X) X) (T (GG (CDR X)))))
;;;gg finds the right most atom
;;;write the definitions of double and gg in a file named abc.def.
;;;the output also goes to the terminal
(dskout (grindef double gg) abc def)
(DEFUN DOUBLE (X) (CONS X X))
(DEFUN GG (X) (COND ((ATOM X) X) (T (GG (CDR X)))))
(DSK (4 1002))
;;;dskout creates a file called abc.def (and hence destroys any
;;;old file having the same name. It returns the device and directory
;;; where the file was written.
;;;trace gg
(trace gg)
(FASLOAD TRACE FASL SYS (4 1002)) FILE NOT FOUND
;BKPT FAIL-ACT
;;;this problem was induced by a system change made
;;;after the current version of MACLISP was put up.
;;;to get trace and other system functions not already
;;;present first get fasfix.lsp from the cs206 area
(dskin fasfix lsp cs206)
FASFIX
DONE
;;;now do (faxfix f1 ... fn) where fi are MACLISP
;;;system functions not already loaded. trace is one such.
(fasfix trace)
;LOADING TRACE 59
(DSK (4 1002))
(trace gg)
(GG)
;;;now execute gg
(gg '(a b . c))
(1 ENTER GG ((A B . C)))
(2 ENTER GG ((B . C)))
(3 ENTER GG (C))
(3 EXIT GG C)
(2 EXIT GG C)
(1 EXIT GG C) C
;;;trace is useful for debugging
;;;when a traced function is entered (level ENTER fname arglist) is printed
;;;when a traced function is exited (level EXIT fname result) is printed
;;;however you may not want the function traced at a later time, so
(untrace gg)
(GG)
(gg '(a b . c))
C
;;;thats all for now folks
↑C
@
.end "session"
.ss Suggestions for Homework Preparation.
Some of the homework for CS206 involves writing LISP programs to
compute some given recursive functions. The student is expected to
debug the programs then turn in the following things for each program:
.item←0
.begin nofill
#. The internal form of the program.
#. The corresponding external form recursive definition.
#. A description of how the progam works and why.
#. Output from test runs on a variety of input.
.end
This collection of data can be put together in many ways. The following
procedure is just one possiblity.
.begin indent 4,8
.item←0
#. Using some editor available at LOTS create a file and type in the
programs you wish to test. This allows you to use the editor to
correct typos. Parenthesis matching is essential here, so check it
carefully.
#. When you think your programs are correctly written run LISP and
read in the file (using $DSKIN or $UREAD). Now try your functions
on some trivial cases. If you discover some bugs fix them
using the LISP editor and $SAVE or $REFILE the new versions.
Now test them on non trivial data until you are convinced they
are correct.
#. To get a "pretty printed" version of your definitions you can
$$(GRINDEF_f1_..._fn)$ where $fi are function names
(atoms with an $EXPR property). This can be written on a file
using $DSKOUT.
#. To get output from sample runs the LOTS "PHOTO" program is useful.
PHOTO creates a file in which it keeps a log of what you type to
the terminal and what it types back. Type HELP PHOTO to the monitor
to find out how to use it.
#. Finally you can edit the file containing the pretty printed versions
of your programs and add external form definitions and documentation
for each program, list this and the PHOTO file and turn them in.
.end
There are many variations on the above procedure. You will no doubt
develop your own style and preferences. This is intended only to
get you going and point out some of the possibilities in the case that
you are unfamiliar with LOTS, LISP or both.
.GET MICRO.S78[206,LSP]
.GET OLDIO.S78[206,LSP]
.GET EDITOR.S78[206,LSP]
.mkcontents